const {app,globalShortcut} = require('electron')
const path = require('path');
const isDev = require('electron-is-dev');

const {log} = require('../utils/log');
require('dotenv-expand')(
  require('dotenv')
    .config({
      path: path.join(__dirname, '../../', isDev ? '.env.development' : '.env.production')
    })
)

//
log(app.getPath('userData')); //C:\Users\xxx\AppData\Roaming\yueerlan

const {
  handleIPCAndSignal,
  initSignalClient
} = require('./signal');
const {
  create: createMainWindow
} = require('./windows/main');


app.on('ready',async () => {
  await createMainWindow();

  handleIPCAndSignal();

  //注意: 要先注册上面 【handleIPCAndSignal】 里的监听
  //     否则会漏掉 SIGNAL_SERVER:CONNECTED 事件
  initSignalClient();
});
